/*
 * Copyright 2012 Benoît Combe <benoit.combe@gmail.com>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package fr.ipst.spot.formulaires.entites;

import fr.ipst.spot.entites.Auditeur;
import fr.ipst.spot.entites.utils.Departement;
import fr.ipst.spot.entites.utils.Pays;
import fr.ipst.spot.exceptions.SpotExceptionForm;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author Benoît Combe <benoit.combe@gmail.com>
 */
public class FormAuditeur extends FormAbstractHtmlEntite<Auditeur> {

    private String nom;
    private String prenom;
    private String mail;
    private String telephone;
    private String mobile;
    private Date dateNaissance;
    private String numSecu;
    private String ine;
    private String numAuditeur;
    private String adresse;
    private int codePostal;
    private String ville;
    private Pays pays;
    private String villeNaissance;
    private Departement dptNaissance;

    /**
     *
     * @param entity
     */
    public FormAuditeur(Auditeur entity) {
        super(new FormAuditeurId(entity.getId()), entity);
        this.nom = entity.getNom();
        this.prenom = entity.getPrenom();
        this.adresse = entity.getAdresse();
        this.codePostal = entity.getCodePostal();
        this.dateNaissance = entity.getDateNaissance();
        this.dptNaissance = entity.getDeptNaissance();
        this.ine = entity.getIne();
        this.mail = entity.getMail();
        this.mobile = entity.getMobile();
        this.numAuditeur = entity.getNumeroAuditeur();
        this.numSecu = entity.getNumeroSecuSoc();
        this.pays = entity.getPays();
        this.telephone = entity.getTelephone();
        this.ville = entity.getVille();
        this.villeNaissance = entity.getVilleNaissance();
    }

    /**
     *
     * @param request
     */
    public FormAuditeur(HttpServletRequest request) {
        super(new FormAuditeurId(request), request);
        this.nom = this.getNonNullStringFromRequest(request, "nom");
        this.prenom = this.getNonNullStringFromRequest(request, "prenom");
        this.adresse = this.getNonNullStringFromRequest(request, "adresse");
        this.codePostal = this.getIntegerFromRequest(request, "codePostal", -1);
        this.dateNaissance = this.getDateFromRequest(request, "dateNaissance", "dd/MM/yyyy");
        this.dptNaissance = Departement.getDepartementbyCodeSql(this.getIntegerFromRequest(request, "dptNaissance", -1));
        this.ine = this.getNonNullStringFromRequest(request, "ine");
        this.mail = this.getNonNullStringFromRequest(request, "mail");
        this.mobile = this.getNonNullStringFromRequest(request, "mobile");
        this.numAuditeur = this.getNonNullStringFromRequest(request, "numAuditeur");
        this.numSecu = this.getNonNullStringFromRequest(request, "numSecu");
        this.pays = Pays.getPaysByCodeSql(this.getIntegerFromRequest(request, "pays", -1));
        this.telephone = this.getNonNullStringFromRequest(request, "telephone");
        this.ville = this.getNonNullStringFromRequest(request, "ville");
        this.villeNaissance = this.getNonNullStringFromRequest(request, "villeNaissance");
    }

    @Override
    protected void validate(boolean creation) throws SpotExceptionForm {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public Auditeur getEntityToPersist() throws SpotExceptionForm {
        return this.garnir(new Auditeur(), true);
    }

    /**
     *
     * @param entityToFeed
     * @return
     * @throws SpotExceptionForm
     */
    @Override
    protected Auditeur garnir(Auditeur entityToFeed, boolean creation) throws SpotExceptionForm {
        entityToFeed.setAdresse(adresse);
        entityToFeed.setCodePostal(codePostal);
        entityToFeed.setDateNaissance(dateNaissance);
        entityToFeed.setDeptNaissance(dptNaissance);
        entityToFeed.setIne(ine);
        entityToFeed.setMail(mail);
        entityToFeed.setMobile(mobile);
        entityToFeed.setNom(nom);
        entityToFeed.setNumeroAuditeur(numAuditeur);
        entityToFeed.setNumeroSecuSoc(numSecu);
        entityToFeed.setPays(pays);
        entityToFeed.setPrenom(prenom);
        entityToFeed.setTelephone(telephone);
        entityToFeed.setVille(ville);
        entityToFeed.setVilleNaissance(villeNaissance);
        return entityToFeed;
    }

    /**
     *
     * @return
     */
    public String getAdresse() {
        return adresse;
    }

    /**
     *
     * @param adresse
     */
    public void setAdresse(String adresse) {
        this.adresse = adresse;
    }

    /**
     *
     * @return
     */
    public int getCodePostal() {
        return codePostal;
    }

    /**
     *
     * @param codePostal
     */
    public void setCodePostal(int codePostal) {
        this.codePostal = codePostal;
    }

    /**
     *
     * @return
     */
    public Date getDateNaissance() {
        return dateNaissance;
    }

    /**
     *
     * @param dateNaissance
     */
    public void setDateNaissance(Date dateNaissance) {
        this.dateNaissance = dateNaissance;
    }

    /**
     *
     * @return
     */
    public Departement getDptNaissance() {
        return dptNaissance;
    }

    /**
     *
     * @param dptNaissance
     */
    public void setDptNaissance(Departement dptNaissance) {
        this.dptNaissance = dptNaissance;
    }

    /**
     *
     * @return
     */
    public String getIne() {
        return ine;
    }

    /**
     *
     * @param ine
     */
    public void setIne(String ine) {
        this.ine = ine;
    }

    /**
     *
     * @return
     */
    public String getMail() {
        return mail;
    }

    /**
     *
     * @param mail
     */
    public void setMail(String mail) {
        this.mail = mail;
    }

    /**
     *
     * @return
     */
    public String getMobile() {
        return mobile;
    }

    /**
     *
     * @param mobile
     */
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    /**
     *
     * @return
     */
    public String getNom() {
        return nom;
    }

    /**
     *
     * @param nom
     */
    public void setNom(String nom) {
        this.nom = nom;
    }

    /**
     *
     * @return
     */
    public String getNumAuditeur() {
        return numAuditeur;
    }

    /**
     *
     * @param numAuditeur
     */
    public void setNumAuditeur(String numAuditeur) {
        this.numAuditeur = numAuditeur;
    }

    /**
     *
     * @return
     */
    public String getNumSecu() {
        return numSecu;
    }

    /**
     *
     * @param numSecu
     */
    public void setNumSecu(String numSecu) {
        this.numSecu = numSecu;
    }

    /**
     *
     * @return
     */
    public Pays getPays() {
        return pays;
    }

    /**
     *
     * @param pays
     */
    public void setPays(Pays pays) {
        this.pays = pays;
    }

    /**
     *
     * @return
     */
    public String getPrenom() {
        return prenom;
    }

    /**
     *
     * @param prenom
     */
    public void setPrenom(String prenom) {
        this.prenom = prenom;
    }

    /**
     *
     * @return
     */
    public String getTelephone() {
        return telephone;
    }

    /**
     *
     * @param telephone
     */
    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    /**
     *
     * @return
     */
    public String getVille() {
        return ville;
    }

    /**
     *
     * @param ville
     */
    public void setVille(String ville) {
        this.ville = ville;
    }

    /**
     *
     * @return
     */
    public String getVilleNaissance() {
        return villeNaissance;
    }

    /**
     *
     * @param villeNaissance
     */
    public void setVilleNaissance(String villeNaissance) {
        this.villeNaissance = villeNaissance;
    }
}
